package edu.cmu.cs.webapp.ioms.ui.providers.ingredient;

import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import edu.cmu.cs.webapp.ioms.models.Ingredient;
import edu.cmu.cs.webapp.ioms.utils.IOMSImageHelper;
import edu.cmu.cs.webapp.ioms.utils.IOMSImages;

public class IngredientInforTableViewerLabelProvider extends
		ColumnLabelProvider implements ITableLabelProvider {

	public static final int INGREDIENT_ID = 0;
	public static final int INGREDIENT_NAME = 1;
	public static final int INGREDIENT_INVENTORY = 2;
	public static final int INGREDIENT_UNIT_COST = 3;
	public static final int INGREDIENT_REMARKS = 4;
	public static final int INGREDIENT_DEMAND = 5;

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		if (element != null) {
			if (columnIndex == INGREDIENT_ID) {
				return IOMSImageHelper.getInstance().getImage(
						IOMSImages.IMG_ING);
			}
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang
	 * .Object, int)
	 */
	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof Ingredient) {
			Ingredient ing = (Ingredient) element;
			switch (columnIndex) {
			case INGREDIENT_ID:
				// id
				return "" + ing.getIng_id();
			case INGREDIENT_NAME:
				// PurchaseOrder status
				return ing.getName();
			case INGREDIENT_INVENTORY:
				// PurchaseOrder date
				return String.valueOf(ing.getInventory());
			case INGREDIENT_UNIT_COST:
				// PurchaseOrder status
				return String.valueOf(ing.getUnit_cost());
			case INGREDIENT_REMARKS:
				// PurchaseOrder status
				return ing.getRemark();
			case INGREDIENT_DEMAND:
				return String.valueOf(ing.getDemand());
			default:
				return "";
			}
		}

		return "";

	}

}
